package com.example.healthmanagement.dao;

import com.example.healthmanagement.entity.HealthAnalysize;
import com.example.healthmanagement.entity.HealthAnalysize;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface HealthAnaRepository extends JpaRepository<HealthAnalysize, Long> {

    List<HealthAnalysize> getHealthAnalysizesByDeleted(Boolean deleted);
    List<HealthAnalysize> getHealthAnalysizesByDeletedAndAnalysizeName(boolean deleted, String name);

    HealthAnalysize findHealthAnalysizeByIdAndDeleted(int id, boolean deleted);

    List<HealthAnalysize> findHealthAnalysizesByDeletedAndAnalysizeNameContaining(boolean deleted, String key);

    @Query("SELECT u FROM HealthAnalysize u WHERE u.deleted = false and u.lastBmiLeft <= :lastBmi and u.lastBmiRight >= :lastBmi and u.nowBmiLeft <= :nowBmi and u.nowBmiRight >= :nowBmi")
    HealthAnalysize findByBmi(double lastBmi, double nowBmi);
}
